home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
iconed1a
/
iconwrks.bas
< prev
next >
Wrap
BASIC Source File
|
1995-04-26
|
38KB
|
1,013 lines
Attribute VB_Name = "Module2"
Option Explicit
#If Win32 Then
DefLng H-I 'h=handle, i = sysint
#Else
DefInt H-I
#End If
Dim HelpFilePath As String
' When either the Editor's colorpalette or the ColorPalette Forms
' ColorPalette need repainting, this routine is called, passing in
' the picture control used for the specific colorpalette.
'
Sub Display_Color_Palette(Pic_ColorPalette As Control)
Dim i%
' The ColorPalettes consist of 3 rows of 16 colors, so to make
' is easy to display and to deterine what color is selected when
' the ColorPalette is click, we set the Scale of the ColorPalette
' to correspond to the number of color rows and columns.
'
Pic_ColorPalette.Scale (0, 0)-(16, 3)
' Display ColorPalette column by column
'
For i% = 0 To 15
'
' Display a column of colors
'
Pic_ColorPalette.Line (i%, 0)-(i% + 1, 1), Colors(i%), BF
Pic_ColorPalette.Line (i%, 1)-(i% + 1, 2), Colors(i% + 16), BF
Pic_ColorPalette.Line (i%, 2)-(i% + 1, 3), Colors(i% + 32), BF
' Display vertical line to left of current columns to visually
' divide the columns, but skip first column, since it is not
' needed due to the Border of the color palette.
'
If i% Then Pic_ColorPalette.Line (i%, 0)-(i%, 3)
Next i%
' Display 2 horizontal lines to visually divide the color rows.
'
Pic_ColorPalette.Line (0, 1)-(16, 1)
Pic_ColorPalette.Line (0, 2)-(16, 2)
End Sub
' Displays the entire or any portion of the grid, when the Grid option
' is active. The 4 paramaters passed in, X1, Y1, X2, Y2, define the
' upper left and lower right corners of the area within the maginified
' Icon that needs the grid displayed.
'
Sub Display_Grid(hDCDest, X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer)
Dim DestX As Integer, DestY As Integer, DestWidth As Integer, DestHeight As Integer
' The grid is not displayed if the icon is being viewed at normal
' size, so check the current value of the scrollbar.
'
If Editor.Scrl_Zoom.Value > Editor.Scrl_Zoom.Min Then
DestX = X1 * PixelSize
DestY = Y1 * PixelSize
DestWidth = (X2 - X1 + 1) * PixelSize
DestHeight = (Y2 - Y1 + 1) * PixelSize
BitBlt hDCDest, X1 * PixelSize, Y1 * PixelSize, DestWidth, DestHeight, Editor.Pic_Grid.hDC, DestX, DestY, SRCAND
End If
End Sub
' Whenever a new color is selected for either the left or right mouse
' button, or the StatusArea needs repainting, this routine is called to
' display the 4 small color squares at the bottom of the StatusArea
' which are filled with the current colors selected for the mouse buttons.
'
Sub Display_Mouse_Colors()
Dim Middle As Integer, i As Integer, X1 As Integer, X2 As Integer, Y1 As Integer, Y2 As Integer
' Calculate the center of the Status bar
'
Middle = Editor.Pic_StatusArea.ScaleWidth \ 2
' Display the 4 color squares
'
For i = 0 To 3
'
' The squares are centered within the left and right halfs of the
' StatusArea, and the width and height are set equal to the Height
' of the Option buttons used to select Left/Right or Screen/Inverse
' colors, so we calculate the corners of the the Color squares
' based on this information.
'
X1 = (i Mod 2) * Middle + (Middle - Editor.Opt_Mouse(i \ 2).Height) \ 2
X2 = X1 + Editor.Opt_Mouse(i \ 2).Height
Y1 = Editor.Opt_Mouse(i \ 2).Top
Y2 = Y1 + Editor.Opt_Mouse(i \ 2).Height
' Draw the color square
'
Editor.Pic_StatusArea.Line (X1, Y1)-(X2, Y2), MouseColors(i), BF
' Draw a black outline around the square
'
Editor.Pic_StatusArea.Line (X1, Y1)-(X2, Y2), BLACK, B
Next i
' Set the CurrentY value of the StatusArea back to that of the
' location where the Mouse Coordinates are displayed, so this
' does not have to be done within each MouseMove event of the
' Edit area.
'
Editor.Pic_StatusArea.CurrentY = Editor.Pic_Icons(5).Top + Editor.Pic_Icons(5).Height + HIGHLIGHT + 1
End Sub
' If a selection has been made, is being made, or a selection is
' being moved, or the Edit area needs repainting while a selection
' is active, this routine is called to display or redisplay a
' rectangle around the current selection.
'
Sub Draw_Selection_Rectangle()
Dim XAdjust As Integer, YAdjust As Integer
' Set drawing mode to INVERSE since this routine also used to erase
' the selection rectangle by simply drawing over the currently displayed
' rectangle
'
Editor.Pic_Edit.DrawMode = INVERSE
' To distinguish between a selection and a selection that is
' being moved, a Dotted line is used for a selection and a solid
' line is used for a selection being moved.
'
If MovingSelection Then Editor.Pic_Edit.DrawStyle = SOLID Else Editor.Pic_Edit.DrawStyle = DOT
' To ensure the entire selection rectangle is visible, the rectangle
' is adjusted inward 1 pixel from the right and bottom if the selection
' contains either the right most column or bottom most row of pixels.
'
If X2Region >= PixelSize * 32 Then XAdjust = 1
If Y2Region >= PixelSize * 32 Then YAdjust = 1
' Draw the selection rectangle.
'
Editor.Pic_Edit.Line (X1Region, Y1Region)-(X2Region - XAdjust, Y2Region - YAdjust), , B
Editor.Pic_Edit.DrawStyle = SOLID
End Sub
' When the currently selected Icon is changed or a new Icon is
' loaded into the currently selected Icon, the bitmaps that make
' of the Icons Mask and Image must be extracted and placed into
' picture controls where they can easily be edited.
'
Sub Extract_Image_And_Mask(Pic_Ctrl As Control)
#If Win32 Then
Dim IPic As IPicture
Dim icoinfo As ICONINFO
Dim PDesc As PICTDESC
Dim hDCWork
Dim hOldWorkBM
Dim hNewBM
Dim hOldMonoBM
GetIconInfo Pic_Ctrl.Picture, icoinfo
hDCWork = CreateCompatibleDC(0)
hNewBM = CreateCompatibleBitmap(Editor.hDC, 32, 32)
hOldWorkBM = SelectObject(hDCWork, hNewBM)
hOldMonoBM = SelectObject(hDCMono, icoinfo.hBMMask)
BitBlt hDCWork, 0, 0, 32, 32, hDCMono, 0, 0, SRCCOPY
SelectObject hDCMono, hOldMonoBM
SelectObject hDCWork, hOldWorkBM
With PDesc
.cbSizeofstruct = Len(PDesc)
.picType = PICTYPE_BITMAP
.Long1 = hNewBM
End With
OleCreatePictureIndirect PDesc, IID_IDispatch, 1, IPic
Editor.Pic_Mask = IPic
Set IPic = Nothing
PDesc.Long1 = icoinfo.hBMColor
OleCreatePictureIndirect PDesc, IID_IDispatch, 1, IPic
Editor.Pic_Image = IPic
DeleteObject icoinfo.hBMMask
DeleteDC hDCWork
#Else
Dim Lpicon As Long
' Get pointer to Icon and prevent Windows form moving it.
'
Lpicon = GlobalLock(Pic_Ctrl.Picture)
' Copy the Icons Mask to Monochrome Bitmap, then copy the MonoBitmap
' the the Picture control.
'
Editor.Pic_Mask.ForeColor = BLACK
SetBitmapBits hBMMono, 128, Lpicon + 12
BitBlt Editor.Pic_Mask.hDC, 0, 0, 32, 32, hDCMono, 0, 0, SRCCOPY
' Copy Icons Image bitmap to Picture control
'
SetBitmapBits Editor.Pic_Image.Image, ImageSize, Lpicon + 12 + 128
' Free icon so Windows is free to move it.
'
GlobalUnlock Pic_Ctrl.Picture
#End If
End Sub
' Displays the selected help topic selected from either
' Editors;' or Viewer's help menu.
'
Sub Get_Help(HelpTopic As Integer)
Dim dummy$
If HelpTopic = MID_USING_HELP Then
'
' "Using Help" was selected so display the Standard Windows Help
' Topic for "Using Help".
'
WinHelp Editor.hWnd, dummy$, HELP_HELPONHELP, 0
Else
' A help topic other the "Using help" was selected.
'
WinHelp Editor.hWnd, HelpFilePath, HELP_CONTEXT, CLng(HelpTopic)
End If
End Sub
Function Help_File_In_Path()
Dim Path As String, CurrentDir As String, SemiColon As Integer, Found